//
//  KongWHightOfLabel.m
//  LoveOfPet
//
//  Created by dllo on 15/11/21.
//  Copyright © 2015年 孔维. All rights reserved.
//

#import "KongWHightOfLabel.h"
#define kHeight     [UIScreen mainScreen].bounds.size.height / 667
#define kWidth      [UIScreen mainScreen].bounds.size.width / 375
@implementation KongWHightOfLabel
+(CGFloat)heightOfLable:(NSString *)text andTextFont:(UIFont *)font andLableWidth:(CGFloat)width andLable:(UILabel *)lable
{
    CGSize size = CGSizeMake(kWidth * width, MAXFLOAT);
    
    lable.numberOfLines = 0;
    
    NSDictionary *attributesDic = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
    
    CGRect frame = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:attributesDic context:nil];
    
    return frame.size.height;
    
    
}
+(CGFloat)labelFitHeight:(NSString *)str label:(UILabel *)label andFontSize:(CGFloat)fontSize
{
    label.numberOfLines = 0;
    UIFont *font = [UIFont systemFontOfSize:fontSize];
    
    label.font = font;
    label.lineBreakMode = NSLineBreakByTruncatingTail;
    label.text = str;
    
    NSDictionary  *dic = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil];
    CGSize actualsize = [str boundingRectWithSize:CGSizeMake(kWidth * 355.f, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
    
    return actualsize.height;
}

+(CGFloat)labelFitHeight:(NSString *)str andFontSize:(CGFloat)fontSize
{
    UIFont *font = [UIFont systemFontOfSize:fontSize];
    
    NSDictionary  *dic = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil];
    CGSize actualsize = [str boundingRectWithSize:CGSizeMake(kWidth * 300.f, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
    
    return actualsize.height;
}

@end
